
class Book:
    def __init__(self, title, author):
        '''初始化方法，在实例化时自动调用'''
        self.title = title  # 标题
        self.author = author  # 作者

    def __str__(self):
        return "%s 写的 《%s》" % (self.author, self.title)

    def __call__(self, *args, **kwargs):
        print("《%s》被当成函数类调用" % self.title)

book1 = Book('Linux运维之道', '丁明一')
s = str(book1)  # str(book1) 实际调用的是 book1.__str__()
print(s)

book1()  # 调用book1函数，实际会调用book1.__call__(实参列表）